<%@   page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<! DOCTYPE   HTML  PUBLIC   "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>编辑</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv = "expires" content = "0">
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="http://www.bootcss.com/p/unslider/style.css">
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/ckeditor/ckeditor.js"></script>
</head>
<body>
	
 <form role="form" action="<%=request.getContextPath()%>/contentAction!doCkEditor.action" method="post">
 	
 	<s:hidden name="tabContentVo.content" id="data" ></s:hidden>
 	<s:hidden name="tabContentVo.id" id="id" ></s:hidden>
 	<s:hidden name="tabContentVo.type" id="type" ></s:hidden>
  <div class="form-group">
  	 <textarea cols="80" id="editor1" name="editor1" rows="10"></textarea>
  </div>
  <div class="form-group">
  	 <input type="button"  class="btn btn-primary" value="保存" onclick="saves();" />
  </div>
 
</form>
</body>
<script>
	
	var editor = CKEDITOR.replace('editor1');
	var data =$("#data").val();
	editor.setData(data);
	
	function saves(){
		var data= encodeURIComponent(editor.getData());
		var id = $.trim($("#id").val());
		var type = $.trim($("#type").val());
		var da = "tabContentVo.id="+id+"&tabContentVo.type="+type+"&tabContentVo.content="+data;
		$.ajax({
            type:"post",
            url: "<%=request.getContextPath()%>/contentAction!doCkEditor.action",
            data:da,
            dataType: "text",
            beforeSend: function (XMLHttpRequest) {
                //$('#show').text("正在查询");
            },
            success: function (data) {
                if(data!=null && data!=""){
					var re = data.split(",")[0];
					if(re=="1"){
						var id = data.split(",")[1];
						$("#id").val(id);
						alert("保存成功！");
					}else{
						alert("保存失败！");
					}
                 }
            },
            error: function (err) {
                alert(err);
            }
        });
	}
</script>
</html>
